|
|
|
|
|
|
|
This use of the CommonDialog control invokes the Windows Help engine by running WINHLP32.EXE. To use the Help dialog box, you must set the CommonDialog control's HelpFile property to the name and location of a properly formatted Windows help (.HLP) file and set the HelpCommand property to tell the Help engine what type of help to offer. After you set these properties, use the CommonDialog control's ShowHelp method to initiate the Help system. The user can then navigate the Help system using your program's Help file. |
|
|
|
|
|
|
|
|
Creating Your Own Dialog Boxes |
|
|
|
|
|
|
|
|
Although the CommonDialog control provides you with several types of dialog boxes to use in your programs, sometimes you just can't accomplish some tasks with these built-in tools. For example, if you want to set your own captions for the command buttons in a dialog box, you can't use the message box; nor can the message box handle more than three buttons (not including the Help button). Also, consider the built-in input box. This dialog box cannot display an icon, nor can it handle more than one input item. If your program needs dialog box capabilities that the CommonDialog control can't offer, you can simply use a standard Visual Basic form to create your own custom dialog box. |
|
|
|
|
|
|
|
|
Creating a Custom Dialog Box |
|
|
|
|
|
|
|
|
You need only follow a few simple guidelines if you decide to create a custom dialog box: |
|
|
|
|
|
|
|
|
Set the form's BorderStyle property to 3 - Fixed Dialog. Standard dialog boxes can't be resized. This property setting also removes the form's Maximize/Restore and Minimize buttons. |
|
|
|
|
|
|
|
|
Remove the form's icon by deleting the setting for its Icon property. |
|
|
|
|
|
|
|
|
Set the form's StartUpPosition property to 1 - CenterOwner so that the dialog box is centered on the parent application. |
|
|
|
|
|
|
|
|
Add controls as necessary to obtain the required information from the user. Use Label controls as captions for text boxes. |
|
|
|
|
|
|
|
|
Use Frame controls to group other controls where appropriate (see the Print range area of the Printer dialog control for an example). |
|
|
|
|
|
|
|
|
Include an OK button that accepts the user's choices. |
|
|
|
|
|
|
|
|
Include a Cancel button that allows the user to abort the action. |
|
|
|
|
|
|
|
|
When you show the dialog box, show it modally (frmDialog.Show vbModal). |
|
|
|
|
|
|
|
|
Feel free to look to some of the standard Windows dialog boxes or to other programs' custom dialog boxes for design ideas. |
|
|
|
|
|
|
|
|
Using Form Templates for Other Dialog Boxes |
|
|
|
|
|
|
|
|
Microsoft has included several form templates with Visual Basic representing custom dialog boxes that can be handy to use in your programs. You can quickly add one of these form |
|
|
|
|
|